# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=php-malware-finder
pkgver=0.3.4.r82.g87b6d7f
pkgrel=1
pkgdesc='Detect potentially malicious PHP files.'
groups=('blackarch' 'blackarch-webapp' 'blackarch-malware' 'blackarch-scanner'
        'blackarch-code-audit')
arch=('x86_64' 'aarch64')
url='https://github.com/jvoisin/php-malware-finder'
license=('LGPL3')
depends=('glibc' 'yara')
makedepends=('git' 'go')
source=("git+https://github.com/jvoisin/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd $pkgname

  GOPATH="$srcdir" go mod download
  GOPATH="$srcdir" go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-s -w" \
    -o $pkgname .
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

	install -Dm 755 $pkgname "$pkgdir/usr/bin/$pkgname"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md CONTRIBUTING.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

